'use strict';
const { timeFormater } = require('../utils/tools');
module.exports = app => {
  const { BIGINT, DATE, TEXT } = app.Sequelize;
  return app.model.define('ConfigJson', {
    id: {
      type: BIGINT,
      allowNull: false,
      primaryKey: true,
      autoIncrement: true,
      field: 'id',
    },
    configJson: {
      type: TEXT,
      allowNull: true,
      field: 'config_json',
    },
    createdTime: {
      type: DATE,
      allowNull: true,
      field: 'created_time',
      get() {
        return timeFormater(this.getDataValue('createdTime'));
      },
    },
    updatedTime: {
      type: DATE,
      allowNull: true,
      field: 'updated_time',
      get() {
        return timeFormater(this.getDataValue('updatedTime'));
      },
    },
  }, {
    tableName: 'config_json',
    timestamps: false,
  });
};
